﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;

namespace Gmantis.Controls.Extended
{
    internal static class FormHelper
    {
        internal static List<T> GetChildObjects<T>(DependencyObject obj) where T : FrameworkElement
        {
            DependencyObject child = null;
            List<T> childList = new List<T>();

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
            {
                child = VisualTreeHelper.GetChild(obj, i);
                if (child is T)
                    childList.Add((T)child);

                childList.AddRange(GetChildObjects<T>(child));
            }

            return childList;
        }
    }
}
